<template>
    <inputSelect  v-model="fgroupid" ref="obj"
                  :f7Param="f7Param" 
                  :f7Disable="disabled"
                  :title="title"
                  :loadShow="loadShow"
                  :onF7DaTaSelected="onF7DaTaSelected"
                  v-on:onF7DaTaSelected="onF7DaTaSelected"
                  >
    </inputSelect>
</template>
<script>
export default {
    name: 'tmdm_material',
    props:{
        disabled : {type : Boolean},
        value : { type: [Number,String] },
        loadShow : {type:[Number]},
        filter : {type : Array,default:null }
    },
    data(){
        return{
            title : '测试用表',
            fgroupid : 0,
            f7Param :{
                    selectId:'fid',
                    selectUrl:'/tie-demo/material/queryListPage',
                    selectTreeField:['fgroupid'],
                    selectTreeUrl:'/tie-demo/materialGroup/queryGroupTree',
                    selectShow:{spt:'',field:['fname']},
                    column:[
                            {lable:'物料编码',prop:'fnumber',isFilter:false,filterField:'xNumber'},
                            {lable:'物料简称',prop:'fsimplename',isFilter:false,filterField:'xId'},
                            {lable:'状态',prop:'fstatus',isFilter:false,filterField:'xDescription'},
                            {lable:'物料名称',prop:'fname',isFilter:false,filterField:'xBeizhu'},
                            {lable:'创建日期',prop:'fcreatetime',isFilter:false,filterField:'xDate'},
                            //{lable:'物料分类',prop:'fgroupid',isFilter:false,filterField:'fGroupId'},
                    ],
                    //defaultFilter:[{field:'fstatus',value:"USED"}]
            },
        }
    },
    created(){
        if(this.filter != null){
            let realFilter = [];
            realFilter = this.f7Param.defaultFilter.concat(this.filter)
            this.f7Param.defaultFilter = realFilter; 
        }
    },
    
    methods:{
       onF7DaTaSelected(row){
           this.$emit('input',row[this.f7Param.selectId])
           this.$emit('change',row)
       },
       cleanF7(){
           this.$refs.obj.cleanF7() 
       },
       defaultSelect(data){
           this.$refs.obj.defaultSelect(data) 
       },
       refresh(filters){
           let realFilter = [];
           if(this.filter!=null){
               realFilter = this.f7Param.defaultFilter.concat(this.filter)
           }
           if(filters != null){
               realFilter = realFilter.concat(filters)
           }
           this.f7Param.defaultFilter = realFilter; 
           this.$refs.obj.refresh() 
       }
    }
}
</script>